package com.example.task;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

@Component
@Aspect
@Order(1)
public class CatAsyncAopService2 {

    @Pointcut("@annotation(com.example.task.CatAsync)")
    public void catAsync() {}


    @Around("catAsync()")
    public void aroundMethod(ProceedingJoinPoint pjp) throws Throwable {
        MethodSignature signature = (MethodSignature) pjp.getSignature();
        Method method = signature.getMethod();
        String transactionName = method.getDeclaringClass().getName() + "." + method.getName();
        System.out.println("--------------------CatAsyncAopService2  begin ---------------------------");
        pjp.proceed();
        System.out.println("--------------------CatAsyncAopService2  end ---------------------------");
    }


}
